package com.lagou.homework.stage01.module02;

public class Task1 {

    public static void main(String[] args) {

        int[][] arr = new int[16][16];

        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                arr[i][j]=i+j;
            }
        }

        Task1 t1 = new Task1();
        t1.sum(arr);
    }

    private void sum(int[][] arr) {
        int result;
        for (int i = 0; i < arr.length; i++) {
            result = 0;
            for (int j = 0; j < arr[i].length; j++) {
                result += arr[i][j];
            }
            System.out.println("第" + (i + 1) + "行的和：" + result);
        }

        for (int j = 0; j < arr[0].length; j++) {
            result = 0;
            for(int i = 0;i<arr.length;i++){
                result +=arr[i][j];
            }
            System.out.println("第" + (j + 1) + "列的和：" + result);
        }

        result = arr[0][0]+arr[0][arr[0].length-1]+arr[arr.length-1][0]+arr[arr.length-1][arr[arr.length-1].length-1];
        System.out.println("四角累加和：" + result);
    }
}
